<template>
  <div class="admin">
    <el-container>
      <el-header>
        <div class="header-logo">摄影作品管理系统</div>
        <div class="user-info">
          <span>{{ nickname }}</span>
          <el-button type="text" @click="logout">退出登录</el-button>
        </div>
      </el-header>
      
      <el-container>
        <el-aside width="200px">
          <el-menu
            :default-active="activeMenu"
            class="el-menu-vertical"
            router
            background-color="#304156"
            text-color="#bfcbd9"
            active-text-color="#409EFF">
            
            <el-menu-item index="/admin/photos">
              <i class="el-icon-picture"></i>
              <span slot="title">作品管理</span>
            </el-menu-item>
            
            <el-menu-item index="/admin/users">
              <i class="el-icon-user"></i>
              <span slot="title">用户管理</span>
            </el-menu-item>
            
            <el-menu-item index="/admin/comments">
              <i class="el-icon-chat-dot-round"></i>
              <span slot="title">评论管理</span>
            </el-menu-item>
            
            <el-menu-item index="/home">
              <i class="el-icon-s-home"></i>
              <span slot="title">返回前台</span>
            </el-menu-item>
          </el-menu>
        </el-aside>
        
        <el-main>
          <router-view />
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'

export default {
  name: 'AdminIndex',
  computed: {
    ...mapGetters(['nickname']),
    activeMenu() {
      return this.$route.path
    }
  },
  methods: {
    logout() {
      this.$store.dispatch('logout')
      this.$router.push('/login')
      this.$message.success('退出登录成功')
    }
  }
}
</script>

<style scoped>
.admin {
  height: 100vh;
}

.el-header {
  background-color: #409EFF;
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
}

.header-logo {
  font-size: 18px;
  font-weight: bold;
}

.user-info {
  display: flex;
  align-items: center;
}

.user-info span {
  margin-right: 10px;
}

.el-aside {
  background-color: #304156;
  height: calc(100vh - 60px);
}

.el-menu {
  border-right: none;
  height: 100%;
}

.el-main {
  background-color: #f0f2f5;
  padding: 20px;
}
</style> 